package day0411;

public class Test08 {
    public static void main(String[] args) {
        int[][] magicSquare = new int[3][3];
        int x = 0, y = 1;
        magicSquare[x][y] = 1;
        for (int num = 2; num <= 9; num++) {
            int nextx = (x - 1 + 3) % 3;
            int nexty = (y + 1) % 3;
            if (magicSquare[nextx][nexty] != 0) {
                x = (x + 1) % 3;
            } else {
                x = nextx;
                y = nexty;
            }
            magicSquare[x][y] = num;
        }
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                System.out.print(magicSquare[i][j] + " ");
            }
            System.out.println();
        }
    }
}